<?php

namespace app\admin\controller\batchpay;

use app\admin\model\Joinpay;
use app\common\controller\Backend;

/**
 * 
 *
 * @icon fa fa-circle-o
 */
class Lists extends Backend
{

    /**
     * Lists模型对象
     * @var \app\admin\model\batchpay\Lists
     */
    protected $model = null;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = new \app\admin\model\batchpay\Lists;
        $this->view->assign("statusList", $this->model->getStatusList());
    }

    public function detail($ids)
    {
        $fieldMap = [
            'id' => 'ID',
            'title' => '标题',
            'createtime' => '创建时间',
            'ordersn' => '订单号',
            'platform_lists_id' => '平台',
            'platform_name' => '平台名称',
            'status' => '代付状态',
            'money' => '代付金额',
            'realmoney' => '实际金额',
            'fee' => '手续费',
            'ratio' => '手续费比例',
            'bankname' => '银行名称',
            'bankcard' => '银行卡号',
            'realname' => '实际人',
            'bankopen' => '开户行',
            'ispublic' => '是否公户',
            'remark' => '备注',
            'callbackurl' => '回调地址',
            'payplatform' => '支付平台',
            'platform' => '平台',
            'appid' => 'AppID',
            'status_text' => '状态',
            'statuscode' => '三方状态码',
            'statusmsg' => '三方信息',
            'platformSerialNo' => '平台单号',
            'notify_status' => '回调状态'
        ];

        $row = $this->model->get(['id' => $ids]);
        if (!$row) {
            $this->error(__('No Results were found'));
        }
        if ($this->request->isAjax()) {
            $this->success("Ajax请求成功", null, ['id' => $ids]);
        }

        if ($row){
            $rows = $row->toArray();
            foreach ($rows as $key => &$value) {
                if ($key == 'status' || $key == 'platform_lists_id') {
                    unset($rows[$key]);
                }
                if ($key == 'createtime') {
                    $value = date('Y-m-d H:i:s', $value);
                }
                if ($key == 'ispublic') {
                    $value = $value==0?'否':'是';
                }
            }
        }

        $this->view->assign("row", $rows);
        $this->view->assign("fieldMap", $fieldMap);

        return $this->view->fetch();
    }



    /**
     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
     */


}
